import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/loading',
    name: 'test',
    component: () => import('../components/testing/loading.vue'),
  },
  {
    redirect:'/managementSystem/statistics',
    path: '/managementSystem',
    name: 'ManagementSystem',
    component: () => import('../views/ManagementSystem.vue'),
    children:[
      {
        path: 'schedulemanagement',
        name: 'ScheduleManagement',
        component: () => import('../components/testing/ScheduleManagement.vue'),
      },
      {
        path: 'statistics',
        name: 'Statistics',
        component: () => import('../views/OutpatientStatistics.vue'),
      },
      {
        path: 'reservation',
        name: 'Reservation',
        component: () => import('../views/NucleicAcidAppointment.vue'),
      },
    ],
  },
  {
    path: '/',
    name: 'Login',
    component: Login
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to,form,next)=>{
  document.title = to.name
  next()
})

export default router

